<!-- BEGIN PAGE -->
<div class="page-content">

    <!-- BEGIN PAGE CONTAINER-->
    <div class="container-fluid">

        <!-- BEGIN PAGE HEADER-->
        <div class="row-fluid">

            <div class="span12">

                <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                <h3 class="page-title">

                    Task
                    <small>任务管理</small>

                </h3>

                <ul class="breadcrumb">

                    <li>
                        <i class="icon-home"></i>
                        <a ui-sref="home.index">首页</a>
                        <i class="icon-angle-right"></i>
                    </li>

                    <li><a href="#">任务列表</a></li>
                </ul>
            </div>

        </div>

        <div class="row-fluid">

            <div class="span12">

                <div class="portlet box grey">

                    <div class="portlet-title">
                        <div class="caption"><i class="icon-globe"></i>任务列表</div>
                        <div class="actions">

                            <a ng-click="addTask()" class="btn blue"><i class="icon-pencil"></i> 创建</a>

                        </div>
                    </div>
                    <div class="portlet-body">
                        <div id="sample_1_wrapper" class="dataTables_wrapper form-inline" role="grid">
                            <div class="row-fluid">



                            </div>
                            <table class="table table-striped table-bordered table-hover dataTable"
                                   id="sample_1"
                                   aria-describedby="sample_1_info">
                                <thead>

                                <tr role="row">
                                    <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample_1" rowspan="1"
                                        colspan="1" aria-label="Username: activate to sort column ascending"
                                        style="width: 100px;">序号
                                    </th>

                                    <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1"
                                        aria-label="Joined">任务名称
                                    </th>
                                    <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1"
                                        aria-label="Joined">任务类型
                                    </th>
                                    <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1"
                                        aria-label="Joined">任务总价
                                    </th>
                                    <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1"
                                        aria-label="Joined">任务量
                                    </th>
                                    <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1"
                                        aria-label="Joined">
                                        子任务
                                    </th>
                                    <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1" colspan="1"
                                        aria-label="Joined" style="text-align: center;width:80px;">操作</th>
                                </tr>
                                </thead>


                                <tbody role="alert" aria-live="polite" aria-relevant="all" ng-if="taskList.length != 0">
                                <tr class="gradeX odd"  ng-repeat="item in taskList"
                                    ng-class="{'odd':$odd,'even':$even}">
                                    <td class=" ">{{params.size*(currentPage-1)+$index+1}}</a></td>
                                    <td class=" "><a ui-sref="home.taskDetail({task_id:item.task_id})">{{item.task_name}}</a></td>
                                    <td class=" " ng-if="item.task_type == 1">普通任务</td>
                                    <td class=" " ng-if="item.task_type == 2">红包任务</td>
                                    <td class="center hidden-480 ">{{item.task_money}}元</td>
                                    <td class="center hidden-480 ">剩余{{item.task_left_quantity}}件/总量{{item.task_total_quantity}}件</td>
                                    <td class="center hidden-480 ">
                                        <table>
                                            <tr ng-repeat="list in item.childTask" style="border:0"><td style="border-style:none;">{{list.task_item_name}}</td></tr>
                                        </table>
                                    </td>

                                    <td style="text-align: center" class="center hidden-480 ">
                                        <a ng-if="item.status != 2" ng-click="changeTaskStatus(item.task_id,2)"><div>启用</div></a>
                                        <div ng-if="item.status == 2">已启用</div>
                                        <a ng-if="item.status == 2" ng-click="changeTaskStatus(item.task_id,3)"><div>停用</div></a>
                                        <div ng-if="item.status != 2">已停用</div>
                                        <a><div ng-click="editor(item.task_id)">编辑</div></a>
                                        <a><div ng-click="delete(item.task_id)">删除</div></a>

                                    </td>
                                </tr>

                                </tbody>
                            </table>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="dataTables_info" id="sample_1_info">当前 {{pageStart}} 到 {{pageEnd}} 共 {{count}} 条记录
                                    </div>
                                </div>
                                <div class="span6" style="text-align: center;width: 100%;">
                                    <div class="dataTables_paginate paging_bootstrap pagination">
                                        <pagination>
                                            <ul num-pages="numPages" current-page="currentPage"
                                                on-select-page="selectPage(page)">
                                                <li class="prev" ng-class="{disabled: noPrevious()}"><a
                                                        ng-click="selectPrevious()">&laquo; </a>
                                                </li>
                                                <li ng-if="judge(page,$index)" ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                                                        ng-click="selectPage(page)" ng-if="!point[$index]">{{page}}</a> <span ng-if="point[$index]">...</span></li>
                                                <li class="next" ng-class="{disabled: noNext()}"><a
                                                        ng-click="selectNext()"> &raquo; </a>
                                                </li>
                                            </ul>
                                        </pagination>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="addTaskModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:850px">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                <h4 class="modal-title" id="myModalLabel">创建任务</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="control-group">
                        <label class="control-label" style="margin-top:10px">任务名称</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.taskName"  >
                        </div>
                        <label class="control-label" style="margin-top:10px">任务类型</label>
                        <div class="controls" style="margin-top:10px">
                            <select
                                    ng-model="task.taskType"
                                    ng-options="o.typeId as o.typeName for o in taskType"
                                    style=" background-color: transparent; border: 1px solid #dddddd; ">
                            </select>
                        </div>

                        <label class="control-label" style="margin-top:10px">图片地址</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="tel"  ng-model="task.icon"  >
                        </div>
                        <label class="control-label" style="margin-top:10px">任务金额</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.taskMoney" placeholder="最多精确到分">
                        </div>
                        <label class="control-label" style="margin-top:10px">任务数量</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.taskQuantity" placeholder="必须填写整数" >
                        </div>
                        <label class="control-label" style="margin-top:10px">子任务数</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.taskItemsNumber" placeholder="必须填写整数">
                        </div>

                        <label class="control-label" style="margin-top:10px">创建子任务:</label>
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>

                                <th style="text-align: center;">任务名称</th>
                                <th style="text-align: center;">任务类型</th>
                                <th style="text-align: center;">金额</th>
                                <th style="text-align: center;">描述</th>
                                <th style="text-align: center;">任务链接</th>
                                <th style="text-align: center;">间隔</th>
                                <th style="text-align: center;">包名/分享标题</th>


                            </tr>
                            </thead>
                            <tr ng-if="task.taskItems.length > 0" ng-repeat='item in task.taskItems'>
                                <td style="text-align: center;"><input type="text" style="width:70px"  ng-model="item.taskItemName"></td>
                                <!--<td style="text-align: center;"><input type="text" style="width:60px"  ng-model="item.taskItemtype"></td>-->
                                <td>
                                    <select
                                        ng-model="item.taskItemType"
                                        ng-options="o.typeId as o.typeName for o in taskItemType"
                                        style=" background-color: transparent; border: 1px solid #dddddd;width:100px; ">
                                    </select>
                                </td>
                                <td style="text-align: center;"><input type="text" style="width:40px"  ng-model="item.taskItemMoney"></td>
                                <td style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.describe"></td>
                                <td style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.taskItemLink"></td>
                                <td style="text-align: center;"><input type="text" style="width:40px"  ng-model="item.openTimeInterval"></td>
                                <td style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.packetName"><a ng-click="deleteTaskItem($index)">删除</a></td>

                            </tr>


                        </table>
                        <a ng-click="addTaskItem()"><img src="images/plus.jpg" style="width:40px" /></a>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" ng-click="createTask()">添加</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>


<div class="modal fade" id="updateTaskModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:850px">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
                <h4 class="modal-title" id="updateModalLabel">编辑任务</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                    <div class="control-group">
                        <label class="control-label" style="margin-top:10px">任务名称</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.task_name"  >
                        </div>
                        <label class="control-label" style="margin-top:10px">图片地址</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="tel"  ng-model="task.task_icon"  >
                        </div>
                        <!--<label class="control-label" style="margin-top:10px">任务金额</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.task_money" placeholder="最多精确到分">
                        </div>-->
                        <label class="control-label" style="margin-top:10px">任务总数量</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.task_total_quantity" placeholder="必须填写整数" >
                        </div>
                        <label class="control-label" style="margin-top:10px">任务剩余数量</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.task_left_quantity" placeholder="必须填写整数" >
                        </div>
                        <!--<label class="control-label" style="margin-top:10px">子任务数</label>
                        <div class="controls" style="margin-top:10px">
                            <input type="text"  ng-model="task.task_items_number" placeholder="必须填写整数">
                        </div>-->

                        <!--<label class="control-label" style="margin-top:10px">子任务列表:</label>
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>

                                <th style="text-align: center;">任务名称</th>
                                <th style="text-align: center;">任务类型</th>
                                <th style="text-align: center;">金额</th>
                                <th style="text-align: center;">描述</th>
                                <th style="text-align: center;">任务链接</th>
                                <th style="text-align: center;">间隔</th>
                                <th style="text-align: center;">包名/分享标题</th>


                            </tr>
                            </thead>
                            <tr ng-if="task.childTask.length > 0" ng-repeat='item in task.childTask'>
                                <td style="text-align: center;"><input type="text" style="width:70px"  ng-model="item.task_item_name"></td>
                                &lt;!&ndash;<td style="text-align: center;"><input type="text" style="width:60px"  ng-model="item.taskItemtype"></td>&ndash;&gt;
                                <td>
                                    <select
                                            ng-model="item.task_item_type"
                                            ng-options="o.typeId as o.typeName for o in taskItemType"
                                            style=" background-color: transparent; border: 1px solid #dddddd;width:100px; ">
                                    </select>
                                </td>
                                <td style="text-align: center;"><input type="text" style="width:40px"  ng-model="item.task_item_money"></td>
                                <td style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.task_item_describe"></td>
                                <td style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.task_item_link"></td>
                                <td style="text-align: center;"><input type="text" style="width:40px"  ng-model="item.open_time_interval"></td>
                                <td ng-if="item.task_item_type != 2" style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.packet_name"><a ng-click=""></a></td>
                                <td ng-if="item.task_item_type == 2" style="text-align: center;"><input type="text" style="width:100px"  ng-model="item.share_title"><a ng-click=""></a></td>

                            </tr>


                        </table>
                        <a ng-click="addTaskItem()"><img src="images/plus.jpg" style="width:40px" /></a>-->

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" ng-click="updateTask(task)">确认修改</button>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

